<template>
  <div class="hello">
    {{count}} <br>
    <button @click="add">+</button>
    <button @click="desc">-</button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  computed:{
    count(){
      return this.$store.state.count;
    }
  },
  methods:{
    add(){
      // this.$store.state.count++
      // this.$store.commit("add",{num:2,text:"加"})
      this.$store.commit({
        type:"add",
        num:2,
        text:"加-"
      })
    },
    desc(){
      // this.$store.state.count--
      this.$store.commit("desc",{num:1,text:"减"})
    }
  }
}
</script>

<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
